--
-- Author: shunguo.chen
-- Date: 2018-02-06 11:20:49
--
-- MapIconRender 地图iconRender

local ClassRef = app.mvc.createRenderClass(...)

--data = 
function ClassRef.createWithData(data, node)
	local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.MapIconNode))
	if node == nil then
		ccui.Helper:doLayout(sprite)
	end
	sprite:init(data)
	return sprite
end     
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end 

-- data = MapInfo
function ClassRef:init(data)
	self.super.init(self, data)

	self._ui.button:addClickEventListener(function(sender, eventType)
	    executeFunc(self._onClick, self)
	end)

	self:refresh()
end

function ClassRef:refresh()
	if self._data then
		self._ui.name:setString(self._data:getName())
	end
end

function ClassRef:setClickEnable(b)
    self._ui.button:setTouchEnabled(b)
    self._ui.button:setEnabled(b)
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef